package com.ruibo.tax.service.impl;

import com.ruibo.tax.model.log.TaxSendLog;
import com.ruibo.tax.mq.send.ReconciliationSendZIPMessage;
import com.ruibo.tax.repository.TaxSendLogRepository;
import com.ruibo.tax.service.TaxSendLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 孙峰
 * @Description: TODO
 * @date 2020/12/22 19:28
 */
@Service
public class TaxSendLogServiceImpl implements TaxSendLogService {


    @Autowired
    private TaxSendLogRepository taxSendLogRepository;

    @Autowired
    private ReconciliationSendZIPMessage reconciliationSendZIPMessage;

    /**
     * \
     * 处理实时对账  对方未返回回执的数据
     */

    @Override
    public void processingUnsentData() {

        List<TaxSendLog> taxSendLogList = taxSendLogRepository.findAllBySendStatusAndTimesLessThan(0, 3);
        //  重新发送数据 更新发送次数
        taxSendLogList.forEach(taxSendLog -> {
            reconciliationSendZIPMessage.sendZipMsgToQLHB2SW(taxSendLog.getFile_path());
            taxSendLog.setTimes(taxSendLog.getTimes() + 1);
        });
        taxSendLogRepository.saveAll(taxSendLogList);
    }
}
